home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / comnumb.exe / RTST.CPP < prev    next >
C/C++ Source or Header  |  1992-05-01  |  2KB  |  54 lines

  1. /////////////////////////////////////////////////////////
  2. // rtst.cpp: Test program for rational number class
  3. // Copyright(c) 1992 Azarona Software
  4. /////////////////////////////////////////////////////////
  5. #include <iostream.h>
  6. #include "rational.h"
  7.  
  8. main()
  9. {
  10.   Rational x, y, z;
  11.  
  12.   while(1) {
  13.     cout << "Enter first rational number (w or <n/d>): ";
  14.     cin >> x;
  15.     if (cin) {
  16.        cout << "Enter second rational number (w or <n/d>): ";
  17.        cin >> y;
  18.     }
  19.     if (cin) {
  20.        cout << "-" << x << " = " << (-x) << '\n';
  21.        cout << "-" << y << " = " << (-y) << '\n';
  22.        cout << "+" << x << " = " << (+x) << '\n';
  23.        cout << "+" << y << " = " << (+y) << '\n';
  24.        cout << x << " * " << y << " = " << (x * y) << '\n';
  25.        cout << x << " / " << y << " = " << (x / y) << '\n';
  26.        cout << x << " + " << y << " = " << (x + y) << '\n';
  27.        cout << x << " - " << y << " = " << (x - y) << '\n';
  28.        cout << x << " == " << y << " = " << (x == y) << '\n';
  29.        cout << x << " != " << y << " = " << (x != y) << '\n';
  30.        cout << x << " <= " << y << " = " << (x <= y) << '\n';
  31.        cout << x << " >= " << y << " = " << (x >= y) << '\n';
  32.        cout << x << " < " << y << " = " << (x < y) << '\n';
  33.        cout << x << " > " << y << " = " << (x > y) << '\n';
  34.        cout << x << "++ = ";
  35.        z = x++;
  36.        cout << z << '\n';
  37.        cout << x << "-- = ";
  38.        z = x--;
  39.        cout << z << '\n';
  40.        cout << "++" << x << " = ";
  41.        z = ++x;
  42.        cout << z << '\n';
  43.        cout << "--" << x << " = ";
  44.        z = --x;
  45.        cout << z << '\n';
  46.     }
  47.     else {
  48.        cout << "That's not very rational!\n";
  49.        break;
  50.     }
  51.   }
  52.   return 0;
  53. }
  54.